<template>
  <group>
    <cell v-for="item in deptList" :title="item.deptName" :key="item.deptId"
    :link="{path: '/register/schedule/' +item.deptId}"></cell>
  </group>
</template>

<script>
  import Group from 'vux/src/components/group/index'
  import Cell from 'vux/src/components/cell/index'

  export default {
    components: {
      Group,
      Cell
    },
    methods: {
      getDept () {
        let url = 'https://ydt.xy12345.cn/edot/api/apoRe/getDept'
        let param = {
          orgCode: this.orgCode,
          queryType: 0,
          deptId: ''
        }
        this.$axios.post(url, this.$qs.stringify(param)).then(response => {
          this.deptList = response.data.data.body
          this.deptFormat(this.deptList)
        })
      },
      deptFormat (data) {
        let obj = []
        for (let index in data) {
          let code = data[index].professionCode
          obj.push(code + this.professionCode[code])
        }
        obj = Array.from(new Set(obj))
        for (let index in obj) {
          let x = {
            code: obj[index].substr(0, 2),
            name: obj[index].substr(2)
          }
          this.professionList.push(x)
        }
      }
    },
    mounted () {
      this.$store.commit('updataTitleStatus', '选择科室')
      this.getDept()
      this.$store.commit('updataOrgCodeStatus', this.orgCode)
    },
    data () {
      return {
        orgCode: this.$route.params.id,
        deptList: [],
        professionList: [],
        showContent001: false,
        professionCode: {
          '00': '学科团队',
          '01': '预防保健',
          '02': '全科医学',
          '03': '内科',
          '04': '外科',
          '05': '妇产科',
          '06': '妇女保健科',
          '07': '儿科',
          '08': '小儿外科',
          '09': '儿童保健科',
          '10': '眼科',
          '11': '耳鼻咽喉科',
          '12': '口腔科',
          '13': '皮肤与性病科',
          '14': '医疗美容科',
          '15': '精神卫生科',
          '16': '传染科',
          '17': '结核病科',
          '19': '肿瘤科',
          '20': '急诊医学科',
          '21': '康复医学科',
          '26': '麻醉科',
          '27': '疼痛科',
          '28': '重症医学科',
          '31': '病理科',
          '32': '医学影像科',
          '50': '中医科',
          '51': '民族医学科',
          '52': '中西医结合科',
          '53': '感染管理科',
          '71': '营养科',
          '72': '护理科',
          '73': '医技科',
          '98': '其他'
        }
      }
    }
  }
</script>

<style scoped>

</style>
